package com.Web.ClassType;

import com.DAO.Impl.ClassTypeImpl;
import com.google.gson.Gson;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * @author 20x
 * @date 2024 - 12 -16
 **/
@WebServlet("/ListClassType")
public class ListClassTypeServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("application/json;charset=utf-8");
        PrintWriter out = resp.getWriter();
        Gson gson = new Gson();
        List<String> classTypeList = new ClassTypeImpl().listClassType();
        out.write(gson.toJson(classTypeList));
    }
}
